import { defineConfig } from 'umi';
import routes from './routes';

const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');

const { NODE_ENV, npm_package_version } = process.env;

export default defineConfig({
  antd: {},
  dva: {},
  <%if (css === 'scss') {-%>
  sass: {},
  <%}-%>
  locale: {},
  layout: {},
  dynamicImport: {
    loading: '@/components/Loading',
  },
  nodeModulesTransform: {
    type: 'none',
  },
  history: {
    type: 'hash',
  },
  favicon: 'https://static.biaoguoworks.com/favico.ico',
  routes,
  fastRefresh: {},
  devtool: 'source-map',
  define: {
    NODE_ENV,
    RELEASE_VERSION: npm_package_version,
    SENTRY_DSN:
      'https://9e87ad2d572e48ac95d19ffeb53e3541@sentry.biaoguoworks.com/3',
  },
  cssLoader: {
    localsConvention: 'camelCase',
  },
  chainWebpack(config) {
    // 替换 Moment.js，优化打包大小
    config.plugin('antddayjs').use(AntdDayjsWebpackPlugin);
  },
});
